local lsp_shiji = fk.CreateSkill {
    name = "lsp_shiji",
    tags = { Skill.Compulsory },
}

Fk:loadTranslationTable {
    ["lsp_shiji"] = "施济",
    [":lsp_shiji"] = "锁定技，游戏开始时，其他角色的随机一张手牌视为【无中生有】，此牌结算结束后，若你的手牌不超过存活角色数，你获得此牌。",
}


lsp_shiji:addEffect(fk.GameStart, {
    anim_type = "defensive",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(lsp_shiji.name)
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        for _, i in ipairs(room:getOtherPlayers(player)) do
            local id = table.random(i:getCardIds("h"))
            room:setCardMark(Fk:getCardById(id), "lsp_shiji", 1)
        end
    end
})
lsp_shiji:addEffect("filter", {
    anim_type = "offensive",
    card_filter = function(self, card, player, isJudgeEvent)
        return card:getMark("lsp_shiji") > 0 and table.contains(player:getCardIds("h"), card.id)
    end,
    view_as = function(self, player, to_select)
        return Fk:cloneCard("ex_nihilo", to_select.suit, to_select.number)
    end,
})
lsp_shiji:addEffect(fk.CardUseFinished, {
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(lsp_shiji.name) and data.card and data.card:getMark("lsp_shiji") > 0 and
        player:getHandcardNum() < #player.room.alive_players
        -- and table.find(player.room.alive_players, function(p)
        --         return player:getHandcardNum() < p:getHandcardNum() --手牌全场最多
        --     end)
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        player.room:setCardMark(data.card, "lsp_shiji", 0)
        player.room:moveCardTo(data.card, Card.PlayerHand, player, fk.ReasonJustMove, lsp_shiji.name, nil, true, player)
    end,
})
return lsp_shiji
